package com.bdqn.S64.config;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import sun.security.krb5.internal.Authenticator;

import java.security.Principal;

@RestController
public class CurrentLoginUserController {

    @GetMapping("/getLoginUser1")
    public Authenticator getLoginUser1(Authenticator authenticator){
        return authenticator;
    }

    @GetMapping("/getLoginUser2")
    public Principal getLoginUser2(Principal Principal){
        return Principal;
    }

    @GetMapping("/getLoginUser3")
    public Principal getLoginUser3(){
        //通过安全上下文持有器获取安全上下文,再获取认证信息
        return SecurityContextHolder.getContext().getAuthentication();
    }
}
